if(typeof Ext.user.method.grouproleidstore == 'undefined'){ Ext.user.method.grouproleidstore = Ext.user.method.grouproleid(); }
if(typeof Ext.user.method.roleidstore == 'undefined'){ Ext.user.method.roleidstore = Ext.user.method.roleid('/Role/data/'); }
Ext.user.rolecolumn = new Ext.grid.ColumnModel([
	{xtype: 'gridcolumn',header: '编号',dataIndex: 'id',sortable: true,width: 10,align: 'center'},
	{xtype: 'gridcolumn',header: '职称',dataIndex: 'ename',sortable: true,width: 15},
	{xtype: 'gridcolumn',header: '角色名称',dataIndex: 'name',sortable: true,width: 15},
	{xtype: 'gridcolumn',header: '上级组',sortable: true,width: 20,dataIndex: 'pid',renderer:Ext.user.method.role},
	{xtype: 'gridcolumn', header: '状态',dataIndex: 'status',sortable: true,width: 15,renderer:Ext.user.method.nodestatus},
	{xtype: 'gridcolumn', header: '描述',dataIndex: 'remark',sortable: true,width: 10},
	{xtype: 'gridcolumn', header: '操作',dataIndex: 'id',sortable: true,width: 20,renderer:function(n){return '<a href="javascript:Ext.user.rabc('+n+');">权限设置</a>&nbsp;&nbsp;<a href="javascript:Ext.user.deleterolegrid('+n+');">删除</a>'}}
]);
Ext.user.roledatalist = Ext.extend(Ext.Panel, { 
    border: false,
	title:'',
	renderTo:'role_index',
    initComponent: function() {
        this.items = [
            {
				border: false,
                id:'rolelist',
				xtype: 'editorgrid', 
				title: '角色列表', 
				store: 'RoleStore', 
				height: window.parent.Ext.getCmp('center_6').getHeight() - 28, 
				loadMask: true, 
				trackMouseOver:true,
				columnLines:true,
				cm: Ext.user.rolecolumn,
				sm: new Ext.grid.RowSelectionModel({ 
					singleSelect: true//如果不想强制每次只能选一行，可以把这句代码注释掉 
				}),
				tbar: [
					{
						text: '添加组',
						handler:function(){
							var RoleWindow = new Ext.user.RoleWindow();
							RoleWindow.show();											
						},
					}
				],
				listeners:{
					rowdblclick:function(g, n, e){
						var user = new Ext.user.RoleWindow({edit:true});
						user.setTitle('修改信息');
						user.show();
						Ext.Ajax.request({
						   url: Ext.user.baseUrl + '/Role/data/',
						   method:'POST',
						   callback:function(o,s,r){
								var data = Ext.util.JSON.decode(r.responseText);
								var Record = Ext.data.Record.create(['name','pid','remark','ename','status']);
								var dataform = Ext.getCmp('RoleWindowform');
								dataform.form.loadRecord(new Record(data));
						   },
						   params: {where:g.getSelectionModel().getSelected().id,do:'grouproleid'}
						});
                       
						Ext.getCmp('RoleWindowform').add(new Ext.form.Hidden({name:'id',value:g.getSelectionModel().getSelected().id,renderTo:'RoleWindowformid'}));
					}
				},
			    viewConfig: {forceFit: true}
            }
        ];
		this.bbar = new Ext.PagingToolbar({
            pageSize: Ext.sysconfig.pageSize,
            store: 'RoleStore',
            displayInfo: true,
            displayMsg: Ext.sysconfig.pagemsg,
            emptyMsg: Ext.sysconfig.emptyList
        });
        Ext.user.roledatalist.superclass.initComponent.call(this);
    }
});

Ext.user.roleproxy = new Ext.data.HttpProxy({
    api: {
		read : Ext.user.baseUrl +'/Role/data/',
		destroy: Ext.user.baseUrl +'/Role/delete/'
	}
});
Ext.user.roleliststoreWriter = new Ext.data.JsonWriter({
    encode: false
});
//数据
Ext.user.roledata = Ext.extend(Ext.data.JsonStore, {
    constructor: function(cfg) {
        cfg = cfg || {};
        Ext.user.roledata.superclass.constructor.call(this, Ext.apply({
            storeId: 'RoleStore',
			proxy:Ext.user.roleproxy,
            writer:Ext.user.roleliststoreWriter,
            autoLoad: true,
			root:'list',
			totalProperty: 'count',
			paramNames:{start:'page',limit:'limit'},
            fields: ['id','name','pid','status','remark','ename']
        }, cfg));
    }
});
